<template>
  <a-card :bordered="false">
    <div style="padding: 14px 0">
      <div style="display: flex; margin-top: 20px;">
        <div style="width: 140px; line-height: 32px; font-weight: bold; color: #000"> {{ $t('协议内容') }}</div>
        <a-row :gutter="[0, 24]" style="width: calc(100% - 140px)">
          <a-col :span="24">
            <j-editor v-model="info.content" />
          </a-col>
          <a-col :span="24">
            <a-button @click="saveInfo" style="background-color: #f96455; border-color: #f96455; color: #ffffff"
              v-has="'BisLiability:edit'">
              {{ $t('保存') }}</a-button>
          </a-col>
        </a-row>
      </div>
    </div>
  </a-card>
</template>

<script>

import { getAction, httpAction } from '@/api/manage';

export default {
  name: 'BisLiabilityList',
  components: {
  },
  data() {
    return {
      description: '协议管理',
      info: {},
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    saveInfo() {
      let url = '', method = '', querydata = {}
      if (this.info.id) {
        url = '/game/bisLiability/edit'
        method = 'put'
      } else {
        url = '/game/bisLiability/add'
        method = 'post'
      }
      querydata = Object.assign({}, this.info, {
        content: this.info.content
      })
      httpAction(url, querydata, method).then((res) => {
        if (res.success) {
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
    },
    getList() {
      getAction('/game/bisLiability/list', {}).then((res) => {
        if (res.success) {
          if (res.result.records.length > 0) {
            this.info = res.result.records[0]
          }
        } else {
          this.$message.warning(res.message)
        }
      })
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>